/*******************************************************
> Copyright (C) 2024 ==IOT== All rights reserved.
> File Name: inherit5.cpp
> Author: IOT
> Website:www.slq.org
> Created Time: 2024年10月25日 星期五 11时10分27秒
***************************************************/

#include <iostream>
using namespace std;

class Base {
	int m = 13;
	public:
	virtual void show()
	{
		cout << "this is base show" << endl;
	}
};

class Derived : public Base {
	
	public:
		virtual void show()
		{
			cout << "this is derived show" << endl;
		}	
};

struct ObjMem {
	void **vptr;
	int data;
};

int cnt;

void print()
{}

typedef void (*fun_t)();

int main(int argc,const char* argv[])
{
	Base base;
	
	cout << "size of base:" << sizeof(base) << endl;
	
	ObjMem *pobj = (ObjMem *)&base;
	cout << pobj->vptr << endl;
	cout << pobj->data << endl;
	
	int *pi = new int;
	cout << "addr of cnt:" << &cnt << endl;
	cout << "malloc:" << pi << endl;
	cout << "fun addr:" << (void *)&print << endl;
	delete pi;
	
	((fun_t)(pobj->vptr[0]))();
	
	base.show();
	
	Base *po = &base;
	po->show();
	
	Derived der;
	po = &der;
	po->show();
	
	pobj = (ObjMem *)&der;
	((fun_t)(pobj->vptr[0]))();
    return 0;
}
